#!/bin/bash
#--20190620
#support NeoKylin-desktop-6.0,NeoKylin-server-6.5,rhel-6.5,Ubuntu

#sys_bit=`getconf LONG_BIT`
os_ret=-1
#lsb_release = ./lsb_release


function f_platform() {
	system_type=$(python -c 'from os_info import OSINFO;print OSINFO.get_system_type()')
	system_bit=$(python -c 'from os_info import OSINFO;print OSINFO.get_architecture_bit()')

	all_info=$(python -c 'from os_info import OSINFO;print OSINFO().get_all_info()')

}

function f_linuxtype() {
	###linux
	system_name=$(python -c 'from os_info import OSINFO;print OSINFO.get_linux_system_name()')
	system_release=$(python -c 'from os_info import OSINFO;print OSINFO.get_linux_system_release()')
	
	
	if [ "$system_name" = "NeoKylin Linux Desktop" -o "$system_name" = "NeoKylin Desktop" -o "$system_name" = "NeoKylin Linux Advanced Server" ] ;  then
		#echo "${os_id}"
		linux_ret=10010
	elif [ "$system_name" = "Red Hat Enterprise Linux Server" ] ; then
		#echo "${releas}"
		linux_ret=20010
	elif [ "$system_name" = "Ubuntu" ] ; then
		#echo "${sys_name}"
		linux_ret=30010
	elif [ "$system_name" = "Linx" ] ; then
		linx_code=$(python -c 'from os_info import OSINFO;print OSINFO.get_linux_distribution()[2]')
		# linx tang = 60
		# linx song = 80
		if [ "$linx_code" = "tang" ] ;  then
			linux_ret=40060
		elif [ "$linx_code" = "song" ] ; then
			linux_ret=40080
		fi
	else
		linux_ret=-1
	fi
}


function f_ostype() {

  if [ "$system_type" = "Linux" ]; then
		sys_ret=1
		f_linuxtype

	elif [ "$system_type" = "SunOS" ]; then
		system_name=`cat /etc/release | awk -F" " 'NR==1{print $1,$2,$3}'`
		system_release=`showrev | grep version | awk -F":" '{print $2}'`
		sys_ret=2
	fi
}
f_platform
f_ostype

case "$1" in
--os-info)
echo "系统信息"
echo "====================================="
echo "$all_info"
echo "===================================="
;;
esac
